class LevelScore {
    score = 0
    level = 1
    scoreEle: HTMLElement
    levelEle: HTMLElement
    
    maxLevel:number   // 最高等级
    upScore:number   // 晋级的分数

    constructor(maxLevel:number = 10,upScore:number = 10){
        this.scoreEle = document.getElementById('score') as HTMLElement
        this.levelEle = document.getElementById('level') as HTMLElement
        this.maxLevel = maxLevel
        this.upScore = upScore
    }
    // 增加分数；如果满足晋级分数才能晋级
    addScore(){
        this.scoreEle.innerHTML = ++this.score + ''
        if(this.score % this.upScore === 0){
            this.addLevel()
        }
    }
    // 晋级，如果等级小于设定的最高级，才执行
    addLevel(){
        if(this.level < this.maxLevel){
            this.levelEle.innerHTML = ++this.level  + ''
        }
    }
}

export default LevelScore